/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.repository.mapper.manage;

import cn.ac.nercis.pes.model.bo.doc.report.unit.EvaluationUnitBO;
import cn.ac.nercis.pes.model.dto.manage.EvaluationUnitDTO;
import cn.ac.nercis.pes.repository.model.manage.EvaluationUnitDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * 测评单位类型映射
 *
 * @author zpy
 * @version 1.0.01
 */
@Mapper(componentModel = "spring",
        unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface EvaluationUnitMapper {
    EvaluationUnitMapper INSTANCE = Mappers.getMapper(EvaluationUnitMapper.class);

    EvaluationUnitDTO toDTO(EvaluationUnitDO entity);

    @Mapping(target = "id", source = "source.id")
    @Mapping(target = "name", source = "dto.name")
    @Mapping(target = "shortName", source = "dto.shortName")
    @Mapping(target = "address", source = "dto.address")
    @Mapping(target = "postalCode", source = "dto.postalCode")
    @Mapping(target = "contactPerson", source = "dto.contactPerson")
    @Mapping(target = "contactPosition", source = "dto.contactPosition")
    @Mapping(target = "contactDepartment", source = "dto.contactDepartment")
    @Mapping(target = "contactTel", source = "dto.contactTel")
    @Mapping(target = "contactPhone", source = "dto.contactPhone")
    @Mapping(target = "contactEmail", source = "dto.contactEmail")
    EvaluationUnitDO toDO(EvaluationUnitDO source,EvaluationUnitDTO dto);

    EvaluationUnitBO toEvaluationUnitBO(EvaluationUnitDO evaluationUnitDO);
}